package com.afkt.project.ui.slice;

import com.ohos.afkt.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.window.dialog.ToastDialog;
import ohos.app.Context;
import ohos.miscservices.wallpaper.WallpaperController;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class WallPaperSlice extends AbilitySlice {

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_layout_wallPaper);


        findComponentById(ResourceTable.Id_button_wallPaper).setClickedListener(component -> {
//                try {
//                    String relativelyPath=System.getProperty("cat.jpg");
//                    FileInputStream inStream = new FileInputStream(relativelyPath);
//
//                    WallpaperController instance = WallpaperController.getInstance((Context) component);
//
//                    instance.setWallpaper(inStream,WallpaperController.WALLPAPER_SYSTEM);
//
//                } catch (FileNotFoundException e) {
//                    e.printStackTrace();
//                }
            new ToastDialog(getContext()).setText("暂不支持此功能").show();
        });
    }


    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

}
